FROM php:7.3-fpm

MAINTAINER phperhuan

# 创建文件夹
RUN mkdir -p /usr/src/php/ext \
	&& mkdir -p /tmp

# 发送本地文件到服务器
ADD ./swoole-4.6.0.tgz /tmp/
ADD ./redis-4.3.0.tgz /tmp/
COPY ./composer.phar /

# 命令行执行（扩展安装）
RUN docker-php-ext-install -j$(nproc) bcmath sockets mysqli pdo_mysql gettext shmop \

    # 更新apt-get
    && echo "" > /etc/apt/sources.list \
    && echo "deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb https://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list \
    && echo "deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list \
    && echo "deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list \
    && cat /etc/apt/sources.list \
    && apt-get update \

    # 安装其他扩展
	&& apt-get install -y --no-install-recommends libzip-dev \
	&& apt-get install -y --no-install-recommends libbz2-dev \
	&& docker-php-ext-install -j$(nproc) zip bz2 \
	&& apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
	&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
	&& docker-php-ext-install -j$(nproc) gd \
	&& rm -r /var/lib/apt/lists/* \

	# 安装swoole扩展
	&& mv /tmp/swoole-4.6.0 /usr/src/php/ext/swoole \
	&& docker-php-ext-install swoole \

	# 安装redis扩展
	&& mv /tmp/redis-4.3.0 /usr/src/php/ext/redis \
	&& docker-php-ext-install redis \

	# 删除不需要的文件
	&& rm -r /tmp/* \

	# 更新composer为最新
    && /composer.phar self-update \